import numpy as np
cimport numpy as cnp

# todo 测试代码

def inverse_transform(cnp.ndarray[cnp.float32_t, ndim=1] xyxy, cnp.ndarray[cnp.float32_t, ndim=2] inverse_transform_matrix):
    """ 根据逆变换矩阵还原坐标
    
    :param xyxy: 长度为4的浮点数数组, 表示: [左上点x坐标, 左上点y坐标, 右下点x坐标, 右下点y坐标]
    :param inverse_transform_matrix: 逆变换矩阵 
    :return: 
    """
    cdef:
        float m_00 = inverse_transform_matrix[0, 0]
        float m_01 = inverse_transform_matrix[0, 1]
        float m_02 = inverse_transform_matrix[0, 2]
        float m_10 = inverse_transform_matrix[1, 0]
        float m_11 = inverse_transform_matrix[1, 1]
        float m_12 = inverse_transform_matrix[1, 1]

    xyxy[0] = m_00 * xyxy[0] + m_01 * xyxy[1] + m_02
    xyxy[1] = m_10 * xyxy[0] + m_11 * xyxy[1] + m_12
    xyxy[2] = m_00 * xyxy[2] + m_01 * xyxy[3] + m_02
    xyxy[3] = m_10 * xyxy[2] + m_11 * xyxy[3] + m_12
